home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / wc90.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  15KB  |  513 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4. /* prototype */
  5. static void wc90_draw_sprites( struct osd_bitmap *bitmap, int priority );
  6.  
  7. unsigned char *wc90_shared;
  8. unsigned char *wc90_tile_colorram, *wc90_tile_videoram;
  9. unsigned char *wc90_tile_colorram2, *wc90_tile_videoram2;
  10. unsigned char *wc90_scroll0xlo, *wc90_scroll0xhi;
  11. unsigned char *wc90_scroll1xlo, *wc90_scroll1xhi;
  12. unsigned char *wc90_scroll2xlo, *wc90_scroll2xhi;
  13. unsigned char *wc90_scroll0ylo, *wc90_scroll0yhi;
  14. unsigned char *wc90_scroll1ylo, *wc90_scroll1yhi;
  15. unsigned char *wc90_scroll2ylo, *wc90_scroll2yhi;
  16.  
  17. size_t wc90_tile_videoram_size;
  18. size_t wc90_tile_videoram_size2;
  19.  
  20. static unsigned char *dirtybuffer1 = 0, *dirtybuffer2 = 0;
  21. static struct osd_bitmap *tmpbitmap1 = 0,*tmpbitmap2 = 0;
  22.  
  23. int wc90_vh_start( void ) {
  24.  
  25.     if ( generic_vh_start() )
  26.         return 1;
  27.  
  28.     if ( ( dirtybuffer1 = malloc( wc90_tile_videoram_size ) ) == 0 ) {
  29.         return 1;
  30.     }
  31.  
  32.     memset( dirtybuffer1, 1, wc90_tile_videoram_size );
  33.  
  34.     if ( ( tmpbitmap1 = osd_new_bitmap(4*Machine->drv->screen_width,2*Machine->drv->screen_height,Machine->scrbitmap->depth ) ) == 0 ){
  35.         free( dirtybuffer1 );
  36.         generic_vh_stop();
  37.         return 1;
  38.     }
  39.  
  40.     if ( ( dirtybuffer2 = malloc( wc90_tile_videoram_size2 ) ) == 0 ) {
  41.         osd_free_bitmap(tmpbitmap1);
  42.         free(dirtybuffer1);
  43.         generic_vh_stop();
  44.         return 1;
  45.     }
  46.  
  47.     memset( dirtybuffer2, 1, wc90_tile_videoram_size2 );
  48.  
  49.     if ( ( tmpbitmap2 = osd_new_bitmap(4*Machine->drv->screen_width,2*Machine->drv->screen_height,Machine->scrbitmap->depth ) ) == 0 ){
  50.         osd_free_bitmap(tmpbitmap1);
  51.         free(dirtybuffer1);
  52.         free(dirtybuffer2);
  53.         generic_vh_stop();
  54.         return 1;
  55.     }
  56.  
  57.     // Free the generic bitmap and allocate one twice as wide
  58.     free( tmpbitmap );
  59.  
  60.     if ( ( tmpbitmap = osd_new_bitmap(2*Machine->drv->screen_width,Machine->drv->screen_height,Machine->scrbitmap->depth ) ) == 0 ){
  61.         osd_free_bitmap(tmpbitmap1);
  62.         osd_free_bitmap(tmpbitmap2);
  63.         free(dirtybuffer);
  64.         free(dirtybuffer1);
  65.         free(dirtybuffer2);
  66.         generic_vh_stop();
  67.         return 1;
  68.     }
  69.  
  70.     return 0;
  71. }
  72.  
  73. void wc90_vh_stop( void ) {
  74.     free( dirtybuffer1 );
  75.     free( dirtybuffer2 );
  76.     osd_free_bitmap( tmpbitmap1 );
  77.     osd_free_bitmap( tmpbitmap2 );
  78.     generic_vh_stop();
  79. }
  80.  
  81. READ_HANDLER( wc90_tile_videoram_r ) {
  82.     return wc90_tile_videoram[offset];
  83. }
  84.  
  85. WRITE_HANDLER( wc90_tile_videoram_w ) {
  86.     if ( wc90_tile_videoram[offset] != data ) {
  87.         dirtybuffer1[offset] = 1;
  88.         wc90_tile_videoram[offset] = data;
  89.     }
  90. }
  91.  
  92. READ_HANDLER( wc90_tile_colorram_r ) {
  93.     return wc90_tile_colorram[offset];
  94. }
  95.  
  96. WRITE_HANDLER( wc90_tile_colorram_w ) {
  97.     if ( wc90_tile_colorram[offset] != data ) {
  98.         dirtybuffer1[offset] = 1;
  99.         wc90_tile_colorram[offset] = data;
  100.     }
  101. }
  102.  
  103. READ_HANDLER( wc90_tile_videoram2_r ) {
  104.     return wc90_tile_videoram2[offset];
  105. }
  106.  
  107. WRITE_HANDLER( wc90_tile_videoram2_w ) {
  108.     if ( wc90_tile_videoram2[offset] != data ) {
  109.         dirtybuffer2[offset] = 1;
  110.         wc90_tile_videoram2[offset] = data;
  111.     }
  112. }
  113.  
  114. READ_HANDLER( wc90_tile_colorram2_r ) {
  115.     return wc90_tile_colorram2[offset];
  116. }
  117.  
  118. WRITE_HANDLER( wc90_tile_colorram2_w ) {
  119.     if ( wc90_tile_colorram2[offset] != data ) {
  120.         dirtybuffer2[offset] = 1;
  121.         wc90_tile_colorram2[offset] = data;
  122.     }
  123. }
  124.  
  125. READ_HANDLER( wc90_shared_r ) {
  126.     return wc90_shared[offset];
  127. }
  128.  
  129. WRITE_HANDLER( wc90_shared_w ) {
  130.     wc90_shared[offset] = data;
  131. }
  132.  
  133. void wc90_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  134. {
  135.     int offs, i;
  136.     int scrollx, scrolly;
  137.  
  138.  
  139.     /* compute palette usage */
  140.     {
  141.         unsigned short palette_map[4 * 16];
  142.         int tile, cram;
  143.  
  144.         memset (palette_map, 0, sizeof (palette_map));
  145.  
  146.         for ( offs = wc90_tile_videoram_size2 - 1; offs >= 0; offs-- )
  147.         {
  148.             cram = wc90_tile_colorram2[offs];
  149.             tile = wc90_tile_videoram2[offs] + 256 * (( cram & 3 ) + ( ( cram >> 1 ) & 4 ));
  150.             palette_map[3*16 + (cram >> 4)] |= Machine->gfx[2]->pen_usage[tile];
  151.         }
  152.         for ( offs = wc90_tile_videoram_size - 1; offs >= 0; offs-- )
  153.         {
  154.             cram = wc90_tile_colorram[offs];
  155.             tile = wc90_tile_videoram[offs] + 256 * (( cram & 3 ) + ( ( cram >> 1 ) & 4 ));
  156.             palette_map[2*16 + (cram >> 4)] |= Machine->gfx[1]->pen_usage[tile];
  157.         }
  158.         for ( offs = videoram_size - 1; offs >= 0; offs-- )
  159.         {
  160.             cram = colorram[offs];
  161.             tile = videoram[offs] + ( ( cram & 0x07 ) << 8 );
  162.             palette_map[1*16 + (cram >> 4)] |= Machine->gfx[0]->pen_usage[tile];
  163.         }
  164.         for (offs = 0;offs < spriteram_size;offs += 16){
  165.             int bank = spriteram[offs+0];
  166.  
  167.             if ( bank & 4 ) { /* visible */
  168.                 int flags = spriteram[offs+4];
  169.                 palette_map[0*16 + (flags >> 4)] |= 0xfffe;
  170.             }
  171.         }
  172.  
  173.         /* expand the results */
  174.         for (i = 0; i < 4*16; i++)
  175.         {
  176.             int usage = palette_map[i], j;
  177.             if (usage)
  178.             {
  179.                 palette_used_colors[i * 16 + 0] = PALETTE_COLOR_TRANSPARENT;
  180.                 for (j = 1; j < 16; j++)
  181.                     if (usage & (1 << j))
  182.                         palette_used_colors[i * 16 + j] = PALETTE_COLOR_USED;
  183.                     else
  184.                         palette_used_colors[i * 16 + j] = PALETTE_COLOR_UNUSED;
  185.             }
  186.             else
  187.                 memset (&palette_used_colors[i * 16 + 0], PALETTE_COLOR_UNUSED, 16);
  188.         }
  189.  
  190.         if (palette_recalc ())
  191.         {
  192.             memset( dirtybuffer,  1, videoram_size );
  193.             memset( dirtybuffer1, 1, wc90_tile_videoram_size );
  194.             memset( dirtybuffer2, 1, wc90_tile_videoram_size2 );
  195.         }
  196.     }
  197.  
  198.  
  199.  
  200.  
  201. /* commented out -- if we copyscrollbitmap below with TRANSPARENCY_NONE, we shouldn't waste our
  202.    time here:
  203.     wc90_draw_sprites( bitmap, 3 );
  204. */
  205.  
  206.     for ( offs = wc90_tile_videoram_size2-1; offs >= 0; offs-- ) {
  207.         int sx, sy, tile;
  208.  
  209.         if ( dirtybuffer2[offs] ) {
  210.  
  211.             dirtybuffer2[offs] = 0;
  212.  
  213.             sx = ( offs % 64 );
  214.             sy = ( offs / 64 );
  215.  
  216.             tile = wc90_tile_videoram2[offs] +
  217.                     256 * (( wc90_tile_colorram2[offs] & 3 ) + ( ( wc90_tile_colorram2[offs] >> 1 ) & 4 ));
  218.  
  219.             drawgfx(tmpbitmap2,Machine->gfx[2],
  220.                     tile,
  221.                     wc90_tile_colorram2[offs] >> 4,
  222.                     0,0,
  223.                     sx*16,sy*16,
  224.                     0,TRANSPARENCY_NONE,0);
  225.         }
  226.     }
  227.  
  228.     scrollx = -wc90_scroll2xlo[0] - 256 * ( wc90_scroll2xhi[0] & 3 );
  229.     scrolly = -wc90_scroll2ylo[0] - 256 * ( wc90_scroll2yhi[0] & 1 );
  230.  
  231.     copyscrollbitmap(bitmap,tmpbitmap2,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  232.  
  233.     wc90_draw_sprites( bitmap, 2 );
  234.  
  235.     for ( offs = wc90_tile_videoram_size-1; offs >= 0; offs-- ) {
  236.         int sx, sy, tile;
  237.  
  238.         if ( dirtybuffer1[offs] ) {
  239.  
  240.             dirtybuffer1[offs] = 0;
  241.  
  242.             sx = ( offs % 64 );
  243.             sy = ( offs / 64 );
  244.  
  245.             tile = wc90_tile_videoram[offs] +
  246.                     256 * (( wc90_tile_colorram[offs] & 3 ) + ( ( wc90_tile_colorram[offs] >> 1 ) & 4 ));
  247.  
  248.             drawgfx(tmpbitmap1,Machine->gfx[1],
  249.                     tile,
  250.                     wc90_tile_colorram[offs] >> 4,
  251.                     0,0,
  252.                     sx*16,sy*16,
  253.                     0,TRANSPARENCY_NONE,0);
  254.         }
  255.     }
  256.  
  257.     scrollx = -wc90_scroll1xlo[0] - 256 * ( wc90_scroll1xhi[0] & 3 );
  258.     scrolly = -wc90_scroll1ylo[0] - 256 * ( wc90_scroll1yhi[0] & 1 );
  259.  
  260.     copyscrollbitmap(bitmap,tmpbitmap1,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  261.  
  262.     wc90_draw_sprites( bitmap, 1 );
  263.  
  264.     for ( offs = videoram_size - 1; offs >= 0; offs-- ) {
  265.         if ( dirtybuffer[offs] ) {
  266.             int sx, sy;
  267.  
  268.             dirtybuffer[offs] = 0;
  269.  
  270.             sx = (offs % 64);
  271.             sy = (offs / 64);
  272.  
  273.             drawgfx(tmpbitmap,Machine->gfx[0],
  274.                     videoram[offs] + ( ( colorram[offs] & 0x07 ) << 8 ),
  275.                     colorram[offs] >> 4,
  276.                     0,0,
  277.                     sx*8,sy*8,
  278.                     0,TRANSPARENCY_NONE,0);
  279.         }
  280.     }
  281.  
  282.     scrollx = -wc90_scroll0xlo[0] - 256 * ( wc90_scroll0xhi[0] & 1 );
  283.     scrolly = -wc90_scroll0ylo[0] - 256 * ( wc90_scroll0yhi[0] & 1 );
  284.  
  285.     copyscrollbitmap(bitmap,tmpbitmap,1,&scrollx,1,&scrolly,&Machine->drv->visible_area,TRANSPARENCY_PEN,palette_transparent_pen);
  286.  
  287.     wc90_draw_sprites( bitmap, 0 );
  288. }
  289.  
  290. #define WC90_DRAW_SPRITE( code, sx, sy ) \
  291.                     drawgfx( bitmap, Machine->gfx[3], code, flags >> 4, \
  292.                     bank&1, bank&2, sx, sy, &Machine->drv->visible_area, TRANSPARENCY_PEN, 0 )
  293.  
  294. static char pos32x32[] = { 0, 1, 2, 3 };
  295. static char pos32x32x[] = { 1, 0, 3, 2 };
  296. static char pos32x32y[] = { 2, 3, 0, 1 };
  297. static char pos32x32xy[] = { 3, 2, 1, 0 };
  298.  
  299. static char pos32x64[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
  300. static char pos32x64x[] = { 5, 4, 7, 6, 1, 0, 3, 2 };
  301. static char pos32x64y[] = { 2, 3, 0, 1,    6, 7, 4, 5 };
  302. static char pos32x64xy[] = { 7, 6, 5, 4, 3, 2, 1, 0 };
  303.  
  304. static char pos64x32[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
  305. static char pos64x32x[] = { 1, 0, 3, 2, 5, 4, 7, 6 };
  306. static char pos64x32y[] = { 6, 7, 4, 5, 2, 3, 0, 1 };
  307. static char pos64x32xy[] = { 7, 6, 5, 4, 3, 2, 1, 0 };
  308.  
  309. static char pos64x64[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
  310. static char pos64x64x[] = { 5, 4, 7, 6, 1, 0, 3, 2, 13, 12, 15, 14, 9, 8, 11, 10 };
  311. static char pos64x64y[] = { 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7,    4, 5 };
  312. static char pos64x64xy[] = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
  313.  
  314. static char* p32x32[4] = {
  315.     pos32x32,
  316.     pos32x32x,
  317.     pos32x32y,
  318.     pos32x32xy
  319. };
  320.  
  321. static char* p32x64[4] = {
  322.     pos32x64,
  323.     pos32x64x,
  324.     pos32x64y,
  325.     pos32x64xy
  326. };
  327.  
  328. static char* p64x32[4] = {
  329.     pos64x32,
  330.     pos64x32x,
  331.     pos64x32y,
  332.     pos64x32xy
  333. };
  334.  
  335. static char* p64x64[4] = {
  336.     pos64x64,
  337.     pos64x64x,
  338.     pos64x64y,
  339.     pos64x64xy
  340. };
  341.  
  342. static void drawsprite_16x16( struct osd_bitmap *bitmap, int code,
  343.                               int sx, int sy, int bank, int flags ) {
  344.     WC90_DRAW_SPRITE( code, sx, sy );
  345. }
  346.  
  347. static void drawsprite_16x32( struct osd_bitmap *bitmap, int code,
  348.                               int sx, int sy, int bank, int flags ) {
  349.     if ( bank & 2 ) {
  350.         WC90_DRAW_SPRITE( code+1, sx, sy+16 );
  351.         WC90_DRAW_SPRITE( code, sx, sy );
  352.     } else {
  353.         WC90_DRAW_SPRITE( code, sx, sy );
  354.         WC90_DRAW_SPRITE( code+1, sx, sy+16 );
  355.     }
  356. }
  357.  
  358. static void drawsprite_16x64( struct osd_bitmap *bitmap, int code,
  359.                               int sx, int sy, int bank, int flags ) {
  360.     if ( bank & 2 ) {
  361.         WC90_DRAW_SPRITE( code+3, sx, sy+48 );
  362.         WC90_DRAW_SPRITE( code+2, sx, sy+32 );
  363.         WC90_DRAW_SPRITE( code+1, sx, sy+16 );
  364.         WC90_DRAW_SPRITE( code, sx, sy );
  365.     } else {
  366.         WC90_DRAW_SPRITE( code, sx, sy );
  367.         WC90_DRAW_SPRITE( code+1, sx, sy+16 );
  368.         WC90_DRAW_SPRITE( code+2, sx, sy+32 );
  369.         WC90_DRAW_SPRITE( code+3, sx, sy+48 );
  370.     }
  371. }
  372.  
  373. static void drawsprite_32x16( struct osd_bitmap *bitmap, int code,
  374.                               int sx, int sy, int bank, int flags ) {
  375.     if ( bank & 1 ) {
  376.         WC90_DRAW_SPRITE( code+1, sx+16, sy );
  377.         WC90_DRAW_SPRITE( code, sx, sy );
  378.     } else {
  379.         WC90_DRAW_SPRITE( code, sx, sy );
  380.         WC90_DRAW_SPRITE( code+1, sx+16, sy );
  381.     }
  382. }
  383.  
  384. static void drawsprite_32x32( struct osd_bitmap *bitmap, int code,
  385.                               int sx, int sy, int bank, int flags ) {
  386.  
  387.     char *p = p32x32[ bank&3 ];
  388.  
  389.     WC90_DRAW_SPRITE( code+p[0], sx, sy );
  390.     WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
  391.     WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
  392.     WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
  393. }
  394.  
  395. static void drawsprite_32x64( struct osd_bitmap *bitmap, int code,
  396.                               int sx, int sy, int bank, int flags ) {
  397.  
  398.     char *p = p32x64[ bank&3 ];
  399.  
  400.     WC90_DRAW_SPRITE( code+p[0], sx, sy );
  401.     WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
  402.     WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
  403.     WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
  404.     WC90_DRAW_SPRITE( code+p[4], sx, sy+32 );
  405.     WC90_DRAW_SPRITE( code+p[5], sx+16, sy+32 );
  406.     WC90_DRAW_SPRITE( code+p[6], sx, sy+48 );
  407.     WC90_DRAW_SPRITE( code+p[7], sx+16, sy+48 );
  408. }
  409.  
  410. static void drawsprite_64x16( struct osd_bitmap *bitmap, int code,
  411.                               int sx, int sy, int bank, int flags ) {
  412.     if ( bank & 1 ) {
  413.         WC90_DRAW_SPRITE( code+3, sx+48, sy );
  414.         WC90_DRAW_SPRITE( code+2, sx+32, sy );
  415.         WC90_DRAW_SPRITE( code+1, sx+16, sy );
  416.         WC90_DRAW_SPRITE( code, sx, sy );
  417.     } else {
  418.         WC90_DRAW_SPRITE( code, sx, sy );
  419.         WC90_DRAW_SPRITE( code+1, sx+16, sy );
  420.         WC90_DRAW_SPRITE( code+2, sx+32, sy );
  421.         WC90_DRAW_SPRITE( code+3, sx+48, sy );
  422.     }
  423. }
  424.  
  425. static void drawsprite_64x32( struct osd_bitmap *bitmap, int code,
  426.                               int sx, int sy, int bank, int flags ) {
  427.  
  428.     char *p = p64x32[ bank&3 ];
  429.  
  430.     WC90_DRAW_SPRITE( code+p[0], sx, sy );
  431.     WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
  432.     WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
  433.     WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
  434.     WC90_DRAW_SPRITE( code+p[4], sx+32, sy );
  435.     WC90_DRAW_SPRITE( code+p[5], sx+48, sy );
  436.     WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 );
  437.     WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 );
  438. }
  439.  
  440. static void drawsprite_64x64( struct osd_bitmap *bitmap, int code,
  441.                               int sx, int sy, int bank, int flags ) {
  442.  
  443.     char *p = p64x64[ bank&3 ];
  444.  
  445.     WC90_DRAW_SPRITE( code+p[0], sx, sy );
  446.     WC90_DRAW_SPRITE( code+p[1], sx+16, sy );
  447.     WC90_DRAW_SPRITE( code+p[2], sx, sy+16 );
  448.     WC90_DRAW_SPRITE( code+p[3], sx+16, sy+16 );
  449.     WC90_DRAW_SPRITE( code+p[4], sx+32, sy );
  450.     WC90_DRAW_SPRITE( code+p[5], sx+48, sy );
  451.     WC90_DRAW_SPRITE( code+p[6], sx+32, sy+16 );
  452.     WC90_DRAW_SPRITE( code+p[7], sx+48, sy+16 );
  453.  
  454.     WC90_DRAW_SPRITE( code+p[8], sx, sy+32 );
  455.     WC90_DRAW_SPRITE( code+p[9], sx+16, sy+32 );
  456.     WC90_DRAW_SPRITE( code+p[10], sx, sy+48 );
  457.     WC90_DRAW_SPRITE( code+p[11], sx+16, sy+48 );
  458.     WC90_DRAW_SPRITE( code+p[12], sx+32, sy+32 );
  459.     WC90_DRAW_SPRITE( code+p[13], sx+48, sy+32 );
  460.     WC90_DRAW_SPRITE( code+p[14], sx+32, sy+48 );
  461.     WC90_DRAW_SPRITE( code+p[15], sx+48, sy+48 );
  462. }
  463.  
  464. static void drawsprite_invalid( struct osd_bitmap *bitmap, int code,
  465.                                             int sx, int sy, int bank, int flags ) {
  466.     logerror("8 pixel sprite size not supported\n" );
  467. }
  468.  
  469. typedef void (*drawsprites_procdef)( struct osd_bitmap *, int, int, int, int, int );
  470.  
  471. static drawsprites_procdef drawsprites_proc[16] = {
  472.     drawsprite_invalid,        /* 0000 = 08x08 */
  473.     drawsprite_invalid,        /* 0001 = 16x08 */
  474.     drawsprite_invalid,        /* 0010 = 32x08 */
  475.     drawsprite_invalid,        /* 0011 = 64x08 */
  476.     drawsprite_invalid,        /* 0100 = 08x16 */
  477.     drawsprite_16x16,        /* 0101 = 16x16 */
  478.     drawsprite_32x16,        /* 0110 = 32x16 */
  479.     drawsprite_64x16,        /* 0111 = 64x16 */
  480.     drawsprite_invalid,        /* 1000 = 08x32 */
  481.     drawsprite_16x32,        /* 1001 = 16x32 */
  482.     drawsprite_32x32,        /* 1010 = 32x32 */
  483.     drawsprite_64x32,        /* 1011 = 64x32 */
  484.     drawsprite_invalid,        /* 1100 = 08x64 */
  485.     drawsprite_16x64,        /* 1101 = 16x64 */
  486.     drawsprite_32x64,        /* 1110 = 32x64 */
  487.     drawsprite_64x64        /* 1111 = 64x64 */
  488. };
  489.  
  490. static void wc90_draw_sprites( struct osd_bitmap *bitmap, int priority ){
  491.     int offs, sx,sy, flags, which;
  492.  
  493.     /* draw all visible sprites of specified priority */
  494.     for (offs = 0;offs < spriteram_size;offs += 16){
  495.         int bank = spriteram[offs+0];
  496.  
  497.         if ( ( bank >> 4 ) == priority ) {
  498.  
  499.             if ( bank & 4 ) { /* visible */
  500.                 which = ( spriteram[offs+2] >> 2 ) + ( spriteram[offs+3] << 6 );
  501.  
  502.                 sx = spriteram[offs + 8] + ( (spriteram[offs + 9] & 1 ) << 8 );
  503.                 sy = spriteram[offs + 6] + ( (spriteram[offs + 7] & 1 ) << 8 );
  504.  
  505.                 flags = spriteram[offs+4];
  506.                 ( *( drawsprites_proc[ flags & 0x0f ] ) )( bitmap, which, sx, sy, bank, flags );
  507.             }
  508.         }
  509.     }
  510. }
  511.  
  512. #undef WC90_DRAW_SPRITE
  513.